using System;
using bitzhuwei.Compiler;

namespace bitzhuwei.JsonFormat {
    partial class CompilerJson {

        public static class reservedWord {
            /// <summary>
            /// {
            /// </summary>
            public const string @LeftBrace符 = "{";
            /// <summary>
            /// }
            /// </summary>
            public const string @RightBrace符 = "}";
            /// <summary>
            /// [
            /// </summary>
            public const string @LeftBracket符 = "[";
            /// <summary>
            /// ]
            /// </summary>
            public const string @RightBracket符 = "]";
            /// <summary>
            /// ,
            /// </summary>
            public const string @Comma符 = ",";
            /// <summary>
            /// :
            /// </summary>
            public const string @Colon符 = ":";
            /// <summary>
            /// null
            /// </summary>
            public const string @null = "null";
            /// <summary>
            /// true
            /// </summary>
            public const string @true = "true";
            /// <summary>
            /// false
            /// </summary>
            public const string @false = "false";

        }

        /// <summary>
        /// if <paramref name="token"/> is a reserved word, assign correspond kind and return true.
        /// <para>otherwise, return false.</para>
        /// </summary>
        /// <param name="token"></param>
        /// <returns></returns>
        private static bool CheckReservedWord(AnalyzingToken token) {
            bool isReservedWord = true;
            switch (token.value) {
            case reservedWord.@LeftBrace符: token.kind = st.@LeftBrace符; break;
            case reservedWord.@RightBrace符: token.kind = st.@RightBrace符; break;
            case reservedWord.@LeftBracket符: token.kind = st.@LeftBracket符; break;
            case reservedWord.@RightBracket符: token.kind = st.@RightBracket符; break;
            case reservedWord.@Comma符: token.kind = st.@Comma符; break;
            case reservedWord.@Colon符: token.kind = st.@Colon符; break;
            case reservedWord.@null: token.kind = st.@null; break;
            case reservedWord.@true: token.kind = st.@true; break;
            case reservedWord.@false: token.kind = st.@false; break;

            default: isReservedWord = false; break;
            }

            return isReservedWord;
        }
    }
}
